package com.bwie.controller;

import com.bwie.pojo.*;
import com.bwie.service.BrandService;
import com.bwie.service.DictService;
import com.bwie.service.ProdAttaService;
import com.bwie.service.ProdService;
import com.bwie.utils.R;
import com.bwie.vo.BrandVo;
import com.bwie.vo.ProdInfoVo;
import com.bwie.vo.ProdVo;
import com.bwie.vo.TypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author: tsh
 * @Date: 2025/7/19 08:38
 * @Description: TODO
 **/
@RestController
@RequestMapping("/goods/index")
@Api(tags = "商品微服务")
public class IndexController {
    @Autowired
    ProdService prodService;
    @Autowired
    BrandService brandService;
    @Autowired
    DictService dictService;
    @Autowired
    ProdAttaService prodAttaService;
    @PostMapping("/getProdList")
    @ApiOperation(value = "商品列表")
    public R getProdList(@RequestBody ProdVo propVo){
        return prodService.getProdList(propVo);
    }
    @PostMapping("/getBrandList")
    @ApiOperation(value = "获取品牌列表")
    public R getBrandList(@RequestBody BrandVo brandVo){
        return brandService.getBrandList(brandVo);
    }
    @PostMapping("/getBrandAll")
    @ApiOperation(value = "获取所有品牌")
    public R getBrandAll(){
        return brandService.getBrandAll();
    }

    @PostMapping("/updateBrandStatus")
    @ApiOperation(value = "修改品牌状态")
    public R updateBrandStatus(@RequestBody Brand brand){
        return brandService.updateBrandStatus(brand);
    }
    @PostMapping("/addBrand")
    @ApiOperation(value = "添加品牌")
    public R addBrand(@RequestBody Brand brand){
        return brandService.addBrand(brand);
    }
    @PostMapping("/getTypeList")
    @ApiOperation(value = "获取商品分类列表")
    public R getTypeList(@RequestBody TypeVo typeVo){
        return prodService.getTypeList(typeVo);

    }
    @PostMapping("/getTypeAll")
    @ApiOperation(value = "获取商品分类列表(下拉框)")
    public R getTypeAll(){
        return prodService.getTypeAll();

    }
    @PostMapping("/uploadFile")
    @ApiOperation(value = "上传图片")
    public R uploadFile(@RequestPart("file")MultipartFile file){
        return prodService.uploadFile(file);
    }
    @PostMapping("/addType")
    @ApiOperation(value = "添加分类")
    public R addType(@RequestBody Type type){
        return prodService.addType(type);
    }

    @PostMapping("/deleteAll")
    @ApiOperation(value = "批量删除")
    public R deleteAll(@RequestBody List<Prod> prodList){
        return prodService.deleteAll(prodList);
    }
    @PostMapping("/getDictList/{typeId}")
    @ApiOperation(value = "获取类型ID获取字典数据")
    public R getDictListById(@PathVariable("typeId") Integer typeId){
        return dictService.getDictListById(typeId);
    }
    @PostMapping("/addProd")
    @ApiOperation(value = "添加商品")
    public R addProd(@RequestBody Prod prod){
        return prodService.addProd(prod);
    }

    @PostMapping("/addAttachment")
    @ApiOperation(value = "添加商品附件")
    public R addAttachment(@RequestBody ProdAtta prodAtta){
        return prodAttaService.addAttachment(prodAtta);
    }
    @PostMapping("/getProdInfoList")
    @ApiOperation(value = "获取所有商品明细")
    public R getProdInfoList(){
        return prodService.getProdInfoList();
    }
/**
 * @description 查看明细
 * @params
 * @param prodId
 * @return com.bwie.utils.R
 * @author tsh
 * @date 2025/7/25 9:47
 */
    @PostMapping("/getProdById/{prodId}")
    @ApiOperation(value = "根据ID查询商品信息")
    public R getProdById(@PathVariable("prodId") Integer prodId){
        return prodService.getProdById(prodId);
    }
    /**
     * @description  根据商品ID获取明细
     * @params 
     * @param prodInfoVo
     * @return com.bwie.utils.R
     * @author tsh
     * @date 2025/7/25 10:26
     */
    @PostMapping("/getProdInfoListAll")
    @ApiOperation(value = "分页获取商品明细")
    public R getProdInfoListAll(@RequestBody ProdInfoVo prodInfoVo){
        return prodService.getProdInfoListAll(prodInfoVo);
    }
    @PostMapping("/addProdInfo")
    @ApiOperation(value = "添加商品明细")
    public R addProdInfo(@RequestBody ProdInfo prodInfo){
        return prodService.addProdInfo(prodInfo);
    }
    

}
